package swing;

import java.awt.Image;
import java.awt.Toolkit;

/**
 *
 * @author CuongVM_B01135
 */
public class ShowMessageDialog extends javax.swing.JDialog {

    public static int STATUS = 0;
    public static final int OK = 1;
    public static final int CANCEL = 0;
    public static final int MESSAGE = 2;
    public static final int CONFIRM = 3;
    Image icon = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/images/question_mark_icon_blueglow.png"));

    public ShowMessageDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.setLocationRelativeTo(null);
        STATUS = 0;
        this.setIconImage(icon);
    }

    public ShowMessageDialog(java.awt.Frame parent, boolean modal, String Message, String Title, int Type) {
        super(parent, modal);
        initComponents();
        message.setText(Message);
        setTitle(Title);
        STATUS = 0;
        if (Type == MESSAGE) {
            btnOK.setVisible(false);
            btnCancel.setVisible(false);
            btnMessageOK.setVisible(true);
        } else if (Type == CONFIRM) {
            btnOK.setVisible(true);
            btnCancel.setVisible(true);
            btnMessageOK.setVisible(false);
        }
        setLocationRelativeTo(this);
        setVisible(true);
    }

    // <editor-fold defaultstate="collapsed" desc="paint">
    /*
    private Image image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/images/dialog.png"));;
    @Override
    public void paint(Graphics g){
    
    g.drawImage(image,0,20,this);
    message.setText(mess);
    add(btnOK);
    add(btnCancel);
    
    }
     * */
    // </editor-fold>
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        message = new javax.swing.JLabel();
        btnOK = new javax.swing.JButton();
        btnCancel = new javax.swing.JButton();
        btnMessageOK = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("");
        setAlwaysOnTop(true);
        setFocusable(false);
        setResizable(false);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        jPanel1.setFocusCycleRoot(true);
        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        message.setBackground(javax.swing.UIManager.getDefaults().getColor("window"));
        message.setFont(new java.awt.Font("Tahoma", 1, 11));
        message.setForeground(new java.awt.Color(186, 25, 25));
        message.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        message.setText("Message");
        message.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        message.setName("message"); // NOI18N
        jPanel1.add(message, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 290, 50));

        btnOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ok.png"))); // NOI18N
        btnOK.setText("OK");
        btnOK.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        btnOK.setFocusable(false);
        btnOK.setMargin(new java.awt.Insets(0, 2, 0, 2));
        btnOK.setName("btnOK"); // NOI18N
        btnOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOKActionPerformed(evt);
            }
        });
        jPanel1.add(btnOK, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 80, 70, 20));

        btnCancel.setBackground(new java.awt.Color(255, 255, 255));
        btnCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/no.png"))); // NOI18N
        btnCancel.setText("Cancel");
        btnCancel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        btnCancel.setFocusable(false);
        btnCancel.setMargin(new java.awt.Insets(0, 2, 0, 2));
        btnCancel.setName("btnCancel"); // NOI18N
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelActionPerformed(evt);
            }
        });
        jPanel1.add(btnCancel, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 80, 70, 20));

        btnMessageOK.setBackground(new java.awt.Color(255, 255, 255));
        btnMessageOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ok.png"))); // NOI18N
        btnMessageOK.setText("OK");
        btnMessageOK.setFocusable(false);
        btnMessageOK.setMargin(new java.awt.Insets(0, 2, 0, 2));
        btnMessageOK.setName("btnMessageOK"); // NOI18N
        btnMessageOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMessageOKActionPerformed(evt);
            }
        });
        jPanel1.add(btnMessageOK, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 80, 70, 20));

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/dialog.png"))); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N
        jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 30, 202, -1));

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
        STATUS = CANCEL;
        dispose();
}//GEN-LAST:event_btnCancelActionPerformed

    private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
        STATUS = OK;
        dispose();
}//GEN-LAST:event_btnOKActionPerformed

    private void btnMessageOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMessageOKActionPerformed
        dispose();
    }//GEN-LAST:event_btnMessageOKActionPerformed
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnMessageOK;
    private javax.swing.JButton btnOK;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel message;
    // End of variables declaration//GEN-END:variables
}
